﻿using github.heerheer.card2.UI.Infos;
using github.heerheer.card2.UI.Pages;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace github.heerheer.card2.UI.Views
{
    /// <summary>
    /// NewsView.xaml 的交互逻辑
    /// </summary>
    public partial class NewsView : UserControl
    {
        public NewsView()
        {
            InitializeComponent();
            var infos = new ObservableCollection<NewsInfo>();
            NewsList.ItemsSource = infos;
            var s = NewsHelper.getNews();
            for (int i = 0; i < s.Count; i++)
            {
                s[i].id = i;
                infos.Add(s[i]);
            }
        }
        private void NewsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (NewsList.SelectedItem == null)
                return;
            var c = (NewsInfo)NewsList.SelectedItem;
            NoticeView n = new NoticeView(c);
            n.Show();
            n.Activate();
        }

    }


}
